﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.ComponentModel.DataAnnotations;

namespace ITProject.WebUI.Models.ProjectAdmin
{
    public class ProjectAdminChangeReleaseStatusViewModel
    {
        [Required(ErrorMessage="Musisz wybrać status")]
        [Display(Name="Nowy status wersji")]
        public string ReturnStatus { get; set; }
        public List<SelectListItem> StatusList { get; set; }
        [Display(Name="Komentarz do zmiany statusu wersji")]
        public string Comment { get; set; }

        // atrybuty ukryte w formularzu
        public string ProjectName { get; set; }
        [Display(Name = "Nazwa wersji")]
        public string ReleaseName { get; set; }

        public static void CompleteStatusList(ProjectAdminChangeReleaseStatusViewModel vm, string currentReleaseStatus)
        {
            vm.StatusList = new List<SelectListItem>();
            vm.StatusList.Add(new SelectListItem { Text = StatusName.Active, Selected = currentReleaseStatus == StatusName.Active ? true : false });
            vm.StatusList.Add(new SelectListItem { Text = StatusName.Planned, Selected = currentReleaseStatus == StatusName.Planned ? true : false });
            vm.StatusList.Add(new SelectListItem { Text = StatusName.Done, Selected = currentReleaseStatus == StatusName.Done ? true : false });
            vm.StatusList.Add(new SelectListItem { Text = StatusName.Tested, Selected = currentReleaseStatus == StatusName.Tested ? true : false });
            vm.StatusList.Add(new SelectListItem { Text = StatusName.Accepted, Selected = currentReleaseStatus == StatusName.Accepted ? true : false });
        }

        public static ProjectAdminChangeReleaseStatusViewModel Convert(string projectName, string releaseName, string currentReleaseStatus)
        {
            ProjectAdminChangeReleaseStatusViewModel vm = new ProjectAdminChangeReleaseStatusViewModel();
            vm.ProjectName = projectName;
            vm.ReleaseName = releaseName;
            ProjectAdminChangeReleaseStatusViewModel.CompleteStatusList(vm, currentReleaseStatus);
            return vm;
        }
    }
}